


namespace apeng {


    /**完成回调处理  */
    export class CompleteCallBack {
        public cb: (...param: any[]) => void = null!
        public _cb: (...param: any[]) => void = null!

        public set(cb: (...param: any[]) => void = null!) {
            this.cb = cb
            this._cb = cb
        }

        public run(...param: any[]) {
            // 避免回调嵌套
            let cb = this.cb
            this.cb = null!
            if (cb)
                return cb(...param)

            return null!
        }

        public clear() {
            this.cb = null!
        }


    }
}